<?php

/**默认逻辑有的会自己预设开奖号码而不是从开奖接口获取**/
/**会预加载一份下期开奖的开奖号码为空的新数据到kjjg_list 表中**/

set_time_limit(0);
error_reporting(0);
date_default_timezone_set("PRC");
require 'db_config.php';

//1.连接数据库->pdo方式
$db_pdo_link = pdo_write_read_link();  //定义为全局变量

if(!$db_pdo_link)
{
	die('pdo connection failed!');
}


//获取接口数据
//$GET_URL_P="http://a.apiplus.net/newly.do?token=E0C5726B8E45A086&rows=5";  //开奖网的token
$GET_URL_P="http://114.215.68.205/kjjg.php";  //自己服务开奖接口

$CH=@CURL_INIT();

@CURL_SETOPT($CH,CURLOPT_URL,$GET_URL_P);

@CURL_SETOPT($CH,CURLOPT_RETURNTRANSFER,1);

@CURL_SETOPT($CH,CURLOPT_HEADER,0);

@CURL_SETOPT($CH,CURLOPT_HTTPHEADER,array("Content-Type: text/xml; charset=utf-8","Expect: 100-continue"));

$GET_ZHI_VP=@curl_exec($CH);

@curl_close($ch);

//file_put_contents('text.txt',$GET_ZHI_VP);
//开奖结果写入redis 
/*redis_kjjg($GET_ZHI_VP);
function redis_kjjg($GET_ZHI_VP){
	$redis = new Redis();
	$redis->connect('10.31.74.145','6379');//205ip
	$redis->auth('Redis');
	$redis->set("kjjg","$GET_ZHI_VP");

}*/

//$GET_ZHI_VP=FILE_GET_CONTENTS($GET_URL_P);

$QJ_TEST_CHULI_1=STR_REPLACE('"','',$GET_ZHI_VP);

$QJ_TEST_CHULI_2=explode("<row",$QJ_TEST_CHULI_1);

$COUNT_ARRAY=COUNT($QJ_TEST_CHULI_2);

$CAIJI_ARRAY=ARRAY();
$YX_COUNT = '';

FOR($A=1;$A<=$COUNT_ARRAY;$A++){
	 
	 $LINSBT=explode("expect=",$QJ_TEST_CHULI_2[$A]);
	 
	 $LINSBT_1=explode("opencode",$LINSBT[1]);
	 
	 $LINSBT_1[0]=STR_REPLACE(" ","",$LINSBT_1[0]);
	 
	 $LINSBT_2=explode("code=",$LINSBT[0]);
	 
	 $LINSBT_2[1]=STR_REPLACE(" ","",$LINSBT_2[1]);
	 
	 $LINSBT_3=explode("opencode=",$QJ_TEST_CHULI_2[$A]);
	 
	 $LINSBT_4=explode("opentime=",$LINSBT_3[1]);
	 
	 $LINSBT_4[0]=STR_REPLACE(" ","",$LINSBT_4[0]);
	 
	 $LINSBT_4[0]=STR_REPLACE(",","",$LINSBT_4[0]);
	 
	 $LINSBT_4[0]=STR_REPLACE("+","",$LINSBT_4[0]);
	 
	 $LINSBT_4[0]=STR_REPLACE("=","",$LINSBT_4[0]);
	 
	 IF($LINSBT_2[1]!="" && $LINSBT_1[0]!="" && $LINSBT_4[0]!="")
	 {
		 
		 $YX_COUNT=$YX_COUNT+1;
	 
		 $CAIJI_ARRAY[$YX_COUNT]=ARRAY();
		 
		 $CAIJI_ARRAY[$YX_COUNT]['czbh']=$LINSBT_2[1];
	 
		 $CAIJI_ARRAY[$YX_COUNT]['qihao']=$LINSBT_1[0];
	 
		 $CAIJI_ARRAY[$YX_COUNT]['kjjg']=$LINSBT_4[0];
		
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="jsk3"){OPENKJJG_RU_SQL("44",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="jx11x5"){OPENKJJG_RU_SQL("25",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="mlaft"){OPENKJJG_RU_SQL("61",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="pl3"){OPENKJJG_RU_SQL("5",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="qxc"){OPENKJJG_RU_SQL("51",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="sd11x5"){OPENKJJG_RU_SQL("28",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="shssl"){OPENKJJG_RU_SQL("48",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 //IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="tjklsf"){OPENKJJG_RU_SQL("62",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="tjssc"){OPENKJJG_RU_SQL("8",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="ahk3"){OPENKJJG_RU_SQL("36",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="bjkl8"){OPENKJJG_RU_SQL("10",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);OPENKJJG_RU_SQL("60",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}  //北京快乐8 和 pc蛋蛋
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="bjpk10"){OPENKJJG_RU_SQL("4",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 //IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="cqklsf"){OPENKJJG_RU_SQL("59",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}  //幸运农场
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="cqssc"){OPENKJJG_RU_SQL("1",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="fc3d"){OPENKJJG_RU_SQL("7",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="gd11x5"){OPENKJJG_RU_SQL("16",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 //IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="gdklsf"){OPENKJJG_RU_SQL("49",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="hk6"){OPENKJJG_RU_SQL("9",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 
		 /*  后续开通了接口权限后再取消注释
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="xjssc"){OPENKJJG_RU_SQL("2",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="hljssc"){OPENKJJG_RU_SQL("3",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="pl5"){OPENKJJG_RU_SQL("6",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="nmgssc"){OPENKJJG_RU_SQL("11",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="ynssc"){OPENKJJG_RU_SQL("12",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="ah11x5"){OPENKJJG_RU_SQL("13",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="bj11x5"){OPENKJJG_RU_SQL("14",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="fj11x5"){OPENKJJG_RU_SQL("15",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}

		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="gs11x5"){OPENKJJG_RU_SQL("17",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="gx11x5"){OPENKJJG_RU_SQL("18",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="gz11x5"){OPENKJJG_RU_SQL("19",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="heb11x5"){OPENKJJG_RU_SQL("20",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="hlj11x5"){OPENKJJG_RU_SQL("21",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="hub11x5"){OPENKJJG_RU_SQL("22",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="jl11x5"){OPENKJJG_RU_SQL("23",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="js11x5"){OPENKJJG_RU_SQL("24",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="ln11x5"){OPENKJJG_RU_SQL("26",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="nmg11x5"){OPENKJJG_RU_SQL("27",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}

		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="sh11x5"){OPENKJJG_RU_SQL("29",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="sxl11x5"){OPENKJJG_RU_SQL("31",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="tj11x5"){OPENKJJG_RU_SQL("32",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="xj11x5"){OPENKJJG_RU_SQL("33",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="yn11x5"){OPENKJJG_RU_SQL("34",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="zj11x5"){OPENKJJG_RU_SQL("35",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="bjk3"){OPENKJJG_RU_SQL("37",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="fjk3"){OPENKJJG_RU_SQL("38",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="gsk3"){OPENKJJG_RU_SQL("39",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="gxk3"){OPENKJJG_RU_SQL("40",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="gzk3"){OPENKJJG_RU_SQL("41",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="hebk3"){OPENKJJG_RU_SQL("42",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="hubk3"){OPENKJJG_RU_SQL("43",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="jxk3"){OPENKJJG_RU_SQL("45",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="nmgk3"){OPENKJJG_RU_SQL("46",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 
		 IF($CAIJI_ARRAY[$YX_COUNT]['czbh']=="shk3"){OPENKJJG_RU_SQL("47",$CAIJI_ARRAY[$YX_COUNT]['kjjg'],$CAIJI_ARRAY[$YX_COUNT]['qihao']);}
		 */
		 
	 }
}

ECHO "开始处理系统彩种的开奖</BR>";

//处理私彩

$KJ_TIME=TIME(); 
 
$SIC_CX=$db_pdo_link->query("SELECT * FROM kkty_kjjg_list WHERE kjjg<1 AND jztime<$KJ_TIME  limit 500");

$SSIC_UL = $SIC_CX->fetchAll(PDO::FETCH_ASSOC);

FOREACH($SSIC_UL as $UL)
{
	//五分时时彩 三分时时彩 十分时时彩 三分赛车 五分快三 五分11选5
	IF($UL['czid']==52 || $UL['czid']==53 || $UL['czid']==54 || $UL['czid']==56 || $UL['czid']==57 || $UL['czid']==58){
		
		 OPENKJJG_RU_SQL($UL['czid'],$UL['ps'],$UL['qihao']);
		
	}
}


//开奖数据入库操作
FUNCTION OPENKJJG_RU_SQL($CZID,$KJJGNS,$QIHAO){
	 
	 global $db_pdo_link;
	 
	 //查询是否存在本期
	 
	 //处理PC蛋蛋开奖结果算法[北京快乐8转换成pc蛋蛋]
	 IF($CZID=="10"){
		 
		 $KJJGS=$KJJGNS;
		 
		 $KJHM_NO_1=substr($KJJGS,0,2)+substr($KJJGS,2,2)+substr($KJJGS,4,2)+substr($KJJGS,6,2)+substr($KJJGS,8,2)+substr($KJJGS,10,2);
		 
		 $KJHM_NO_1=substr($KJHM_NO_1,STRLEN($KJHM_NO_1)-1,1);
		 
		 $KJHM_NO_2=substr($KJJGS,12,2)+substr($KJJGS,14,2)+substr($KJJGS,16,2)+substr($KJJGS,18,2)+substr($KJJGS,20,2)+substr($KJJGS,22,2);
		 
		 $KJHM_NO_2=substr($KJHM_NO_2,STRLEN($KJHM_NO_2)-1,1);
		 
		 $KJHM_NO_3=substr($KJJGS,24,2)+substr($KJJGS,26,2)+substr($KJJGS,28,2)+substr($KJJGS,30,2)+substr($KJJGS,32,2)+substr($KJJGS,34,2);
		 
		 $KJHM_NO_3=substr($KJHM_NO_3,STRLEN($KJHM_NO_3)-1,1);
		 
		 $KJJG_HE=$KJHM_NO_1+$KJHM_NO_2+$KJHM_NO_3;
		 
		 $KJJG=$KJHM_NO_1.$KJHM_NO_2.$KJHM_NO_3."=".$KJJG_HE;
		 
		 $KJJGNS=$KJJG;
		 
	 }
	 
	 if($CZID == '60'){
	     $KJJGNS = substr($KJJGNS,0,40);
	 }
	 
	 $IFCUNZQISHU = $db_pdo_link->query("SELECT * FROM kkty_kjjg_list WHERE qihao='$QIHAO' AND czid=$CZID")->fetch(PDO::FETCH_ASSOC);
	
		 
	 IF($IFCUNZQISHU['kjjg']<1){
		 
		 ECHO "编号为：【".$CZID."】的彩票第：【".$QIHAO."】期正在进行开奖！</BR>";
	 
		 IF($IFCUNZQISHU['id']>0){
			 
			 IF($IFCUNZQISHU['iftz']<1){
				 
				 $db_pdo_link->exec("UPDATE kkty_kjjg_list SET `kjjg`='$KJJGNS',`iftz`='1' WHERE id={$IFCUNZQISHU['id']}");				 
			 }
			 
		 }ELSE{
			 
			 $NTIMS=TIME();
			 
			 $MYSQL_ZHIXING_YUJU_A="`czid`,`qihao`,`jztime`,`kjjg`,`iftz`";
		 
			 $MYSQL_ZHIXING_YUJU_B="'$CZID','$QIHAO','$NTIMS','$KJJGNS','1'";
		 
			 $db_pdo_link->exec("INSERT INTO `kkty_kjjg_list` ($MYSQL_ZHIXING_YUJU_A) VALUES ($MYSQL_ZHIXING_YUJU_B)");
			 
			 
		 }
		 
	 }
	 
}



ECHO "开始处理新的一期开启</BR>";

//处理新的一期开启 

//获取全部彩种

$ALL_CAI_LIST=$db_pdo_link->query("SELECT * FROM kkty_caipai_list")->fetchAll(PDO::FETCH_ASSOC);

FOREACH($ALL_CAI_LIST  AS $CL)
{
	 
	 //循环检查每个彩种的最新一期可以投注是否存在
	 
	 $JZ_TZTM=TIME();
	 
	 $ONE_CAI=$db_pdo_link->query("SELECT * FROM kkty_kjjg_list WHERE czid={$CL['id']} AND kjjg<1 AND jztime>={$JZ_TZTM} order by qihao desc")->fetch(PDO::FETCH_ASSOC);
	 
	 IF($ONE_CAI['id']<1){
		 
		 ECHO "编号为：【".$CL['id']."】的彩种正在开启新的一期</BR>";
		 
		 //重庆时时彩
		 IF($CL['id']==1){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF($HS['qihao']<10){$HS['qihao']="00".$HS['qihao'];}
						 
						 IF($HS['qihao']>9 && $HS['qihao']<100){$HS['qihao']="0".$HS['qihao'];}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //新疆时时彩
		 IF($CL['id']==2){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF($HS['qihao']<10){$HS['qihao']="00".$HS['qihao'];}
						 
						 IF($HS['qihao']>9 && $HS['qihao']<100){$HS['qihao']="0".$HS['qihao'];}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //黑龙江时时彩
		 IF($CL['id']==3){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
					 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."22:40:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 $LOLDS=$db_pdo_link->query("SELECT * FROM kkty_kjjg_list WHERE czid={$CL['id']} order by qihao desc")->fetch(PDO::FETCH_ASSOC);
						 
						 $QIHAO_NEW=$LOLDS['qihao']+1;
						 
						 IF(STRLEN($QIHAO_NEW)==STRLEN($LOLDS['qihao'])){$QIHAO_NEWS=$QIHAO_NEW;}ELSE{$QIHAO_NEWS="0".$QIHAO_NEW;}
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEWS,$SZ_TIME,"");
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 
		 //天津时时彩
		 IF($CL['id']==8){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."22:58:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF($HS['qihao']<10){$HS['qihao']="00".$HS['qihao'];}
						 
						 IF($HS['qihao']>9 && $HS['qihao']<100){$HS['qihao']="0".$HS['qihao'];}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //内蒙古时时彩
		 IF($CL['id']==11){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."21:40:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					 IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF($HS['qihao']<10){$HS['qihao']="00".$HS['qihao'];}
						 
						 IF($HS['qihao']>9 && $HS['qihao']<100){$HS['qihao']="0".$HS['qihao'];}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //云南时时彩
		 
		 IF($CL['id']==12){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."21:30:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF($HS['qihao']<10){$HS['qihao']="00".$HS['qihao'];}
						 
						 IF($HS['qihao']>9 && $HS['qihao']<100){$HS['qihao']="0".$HS['qihao'];}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //北京赛车
		 IF($CL['id']==4){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."23:57:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 $LOLDS=$db_pdo_link->query("SELECT * FROM kkty_kjjg_list WHERE czid={$CL['id']} order by qihao desc")->fetch(PDO::FETCH_ASSOC);
						 
						 $QIHAO_NEW=$LOLDS['qihao']+1;
						 
						 IF(STRLEN($QIHAO_NEW)==STRLEN($LOLDS['qihao'])){$QIHAO_NEWS=$QIHAO_NEW;}ELSE{$QIHAO_NEWS="0".$QIHAO_NEW;}
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEWS,$SZ_TIME,"");
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //排列三
		 IF($CL['id']==5){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 $LOLDS=$db_pdo_link->query("SELECT * FROM kkty_kjjg_list WHERE czid={$CL['id']} order by qihao desc")->fetch(PDO::FETCH_ASSOC);
						 
						 $QIHAO_NEW=$LOLDS['qihao']+1;
						 
						 IF(STRLEN($QIHAO_NEW)==STRLEN($LOLDS['qihao'])){$QIHAO_NEWS=$QIHAO_NEW;}ELSE{$QIHAO_NEWS="0".$QIHAO_NEW;}
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEWS,$SZ_TIME,"");
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 
		 //排列五
		 IF($CL['id']==6){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 $LOLDS=$db_pdo_link->query("SELECT * FROM kkty_kjjg_list WHERE czid={$CL['id']} order by qihao desc")->fetch(PDO::FETCH_ASSOC);
						 
						 $QIHAO_NEW=$LOLDS['qihao']+1;
						 
						 IF(STRLEN($QIHAO_NEW)==STRLEN($LOLDS['qihao'])){$QIHAO_NEWS=$QIHAO_NEW;}ELSE{$QIHAO_NEWS="0".$QIHAO_NEW;}
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEWS,$SZ_TIME,"");
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 
		 //福彩3d
		 IF($CL['id']==7){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 $LOLDS=$db_pdo_link->query("SELECT * FROM kkty_kjjg_list WHERE czid={$CL['id']} order by qihao desc")->fetch(PDO::FETCH_ASSOC);
						 
						 $QIHAO_NEW=$LOLDS['qihao']+1;
						 
						 IF(STRLEN($QIHAO_NEW)==STRLEN($LOLDS['qihao'])){$QIHAO_NEWS=$QIHAO_NEW;}ELSE{$QIHAO_NEWS="0".$QIHAO_NEW;}
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEWS,$SZ_TIME,"");
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //香港六合彩
		 IF($CL['id']==9){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
					 
					 $week = date("w",$XT_TIME);
					 
					 if ($week=='2' || $week=='4' || $week=='0'){    //星期二四日就加2天
						 
						 $SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+2*24*3600)." ".$HS['jztime']);
						 
					 }
					 if ($week=='6'){   //星期6就加3天
						 
						 $SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3*24*3600)." ".$HS['jztime']);
						 
					 }
					 if ($week=='1' || $week=='3' || $week=='5'){   //星期1,3,5就加1天
						
						 $SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+1*24*3600)." ".$HS['jztime']);
						 
					 }
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 $LOLDS=$db_pdo_link->query("SELECT * FROM kkty_kjjg_list WHERE czid={$CL['id']} order by qihao desc")->fetch(PDO::FETCH_ASSOC);
						 
						 $QIHAO_NEW=$LOLDS['qihao']+1;
						 
						 IF(STRLEN($QIHAO_NEW)==STRLEN($LOLDS['qihao'])){$QIHAO_NEWS=$QIHAO_NEW;}ELSE{$QIHAO_NEWS="0".$QIHAO_NEW;}
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEWS,$SZ_TIME,"");
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 
		 //PC蛋蛋
		 IF($CL['id']==10){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."23:55:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 $LOLDS=$db_pdo_link->query("SELECT * FROM kkty_kjjg_list WHERE czid={$CL['id']} order by qihao desc")->fetch(PDO::FETCH_ASSOC);
						 
						 $QIHAO_NEW=$LOLDS['qihao']+1;
						 
						 IF(STRLEN($QIHAO_NEW)==STRLEN($LOLDS['qihao'])){$QIHAO_NEWS=$QIHAO_NEW;}ELSE{$QIHAO_NEWS="0".$QIHAO_NEW;}
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEWS,$SZ_TIME,"");
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 
		 //安徽11选5
		 IF($CL['id']==13){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."22:00:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					 IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 
		 //北京11选5
		 IF($CL['id']==14){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."23:00:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 
		 //福建11选5
		 IF($CL['id']==15){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."22:59:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //广东11选5
		 IF($CL['id']==16){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."23:00:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //甘肃11选5
		 IF($CL['id']==17){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."23:00:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //广西11选5
		 IF($CL['id']==18){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."23:50:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //贵州11选5
		 IF($CL['id']==19){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."22:10:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //河北11选5
		 IF($CL['id']==20){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."22:30:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 
		 //黑龙江11选5
		 IF($CL['id']==21){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."22:35:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		  //湖北11选5
		 IF($CL['id']==22){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."21:55:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //吉林11选5
		 IF($CL['id']==23){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."21:30:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //江苏11选5
		 IF($CL['id']==24){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."22:05:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 
		 //江西11选5
		 IF($CL['id']==25){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."23:00:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 
		 //辽宁11选5
		 IF($CL['id']==26){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."22:30:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //内蒙古11选5
		 IF($CL['id']==27){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."23:00:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //山东11选5
		 IF($CL['id']==28){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."22:50:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //上海11选5
		 IF($CL['id']==29){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."23:50:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //陕西11选5
		 IF($CL['id']==31){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."23:00:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //天津11选5
		 IF($CL['id']==32){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."23:50:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //新疆11选5
		 IF($CL['id']==33){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);
					 
					 IF($SZ_TIME>=$XT_TIME){
						 
						 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."02:00:00");
						 
						 IF($XT_TIME<$PDSHIERD){
							 
							 IF($SZ_TIME<$PDSHIERD){
								 
								 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
								 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
							 
								 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
								 
								 $IFZXWB="2";
								 
							 }
							 
						 }ELSE{
							 
							 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
							 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
							 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
							 
							 $IFZXWB="2";
							 
						 }
						 
						 
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //云南11选5
		 IF($CL['id']==34){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."23:00:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 
		  //浙江11选5
		 IF($CL['id']==35){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."22:30:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 
		 //安徽快三
		 IF($CL['id']==36){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."22:00:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF($HS['qihao']<10){$HS['qihao']="00".$HS['qihao'];}
						 
						 IF($HS['qihao']>9 && $HS['qihao']<100){$HS['qihao']="0".$HS['qihao'];}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 
		 //北京快三
		 IF($CL['id']==37){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."23:40:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 $LOLDS=$db_pdo_link->query("SELECT * FROM kkty_kjjg_list WHERE czid={$CL['id']} order by qihao desc")->fetch(PDO::FETCH_ASSOC);
						 
						 $QIHAO_NEW=$LOLDS['qihao']+1;
						 
						 IF(STRLEN($QIHAO_NEW)==STRLEN($LOLDS['qihao'])){$QIHAO_NEWS=$QIHAO_NEW;}ELSE{$QIHAO_NEWS="0".$QIHAO_NEW;}
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEWS,$SZ_TIME,"");
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //福建快三
		 IF($CL['id']==38){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."21:50:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF($HS['qihao']<10){$HS['qihao']="00".$HS['qihao'];}
						 
						 IF($HS['qihao']>9 && $HS['qihao']<100){$HS['qihao']="0".$HS['qihao'];}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //甘肃快三
		 IF($CL['id']==39){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."22:00:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF($HS['qihao']<10){$HS['qihao']="00".$HS['qihao'];}
						 
						 IF($HS['qihao']>9 && $HS['qihao']<100){$HS['qihao']="0".$HS['qihao'];}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //广西快三
		 IF($CL['id']==40){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."22:18:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF($HS['qihao']<10){$HS['qihao']="00".$HS['qihao'];}
						 
						 IF($HS['qihao']>9 && $HS['qihao']<100){$HS['qihao']="0".$HS['qihao'];}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 
		 //贵州快三
		 IF($CL['id']==41){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."22:00:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF($HS['qihao']<10){$HS['qihao']="00".$HS['qihao'];}
						 
						 IF($HS['qihao']>9 && $HS['qihao']<100){$HS['qihao']="0".$HS['qihao'];}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //河北快三
		 IF($CL['id']==42){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."21:50:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF($HS['qihao']<10){$HS['qihao']="00".$HS['qihao'];}
						 
						 IF($HS['qihao']>9 && $HS['qihao']<100){$HS['qihao']="0".$HS['qihao'];}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 
		 //湖北快三
		 IF($CL['id']==43){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."22:00:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF($HS['qihao']<10){$HS['qihao']="00".$HS['qihao'];}
						 
						 IF($HS['qihao']>9 && $HS['qihao']<100){$HS['qihao']="0".$HS['qihao'];}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //江苏快三
		 IF($CL['id']==44){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."22:08:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF($HS['qihao']<10){$HS['qihao']="00".$HS['qihao'];}
						 
						 IF($HS['qihao']>9 && $HS['qihao']<100){$HS['qihao']="0".$HS['qihao'];}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 
		 //江西快三
		 IF($CL['id']==45){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."22:45:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF($HS['qihao']<10){$HS['qihao']="00".$HS['qihao'];}
						 
						 IF($HS['qihao']>9 && $HS['qihao']<100){$HS['qihao']="0".$HS['qihao'];}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 
		 //内蒙古快三
		 IF($CL['id']==46){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."21:35:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF($HS['qihao']<10){$HS['qihao']="00".$HS['qihao'];}
						 
						 IF($HS['qihao']>9 && $HS['qihao']<100){$HS['qihao']="0".$HS['qihao'];}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //上海快三
		 IF($CL['id']==47){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."22:18:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF($HS['qihao']<10){$HS['qihao']="00".$HS['qihao'];}
						 
						 IF($HS['qihao']>9 && $HS['qihao']<100){$HS['qihao']="0".$HS['qihao'];}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //上海时时乐
		 IF($CL['id']==48){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."21:30:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])>9){$HS['qihao']=FLOOR($HS['qihao']);}ELSE{$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 
		 //广东快乐十分
		 IF($CL['id']==49){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
					 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."23:00:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])<=9){$HS['qihao']="00".FLOOR($HS['qihao']);}ELSEIF(FLOOR($HS['qihao'])>9 && FLOOR($HS['qihao'])<100){$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 
		 //天津快乐十分
		 IF($CL['id']==62){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
					 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."23:00:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])<=9){$HS['qihao']="00".FLOOR($HS['qihao']);}ELSEIF(FLOOR($HS['qihao'])>9 && FLOOR($HS['qihao'])<100){$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 
		 
		 //重庆快乐十分
		 IF($CL['id']==59){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
					 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."23:53:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])<=9){$HS['qihao']="00".FLOOR($HS['qihao']);}ELSEIF(FLOOR($HS['qihao'])>9 && FLOOR($HS['qihao'])<100){$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 
		 //北京快乐8
		 IF($CL['id']==60){
		     
		 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."23:55:00");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 $LOLDS=$db_pdo_link->query("SELECT * FROM kkty_kjjg_list WHERE czid={$CL['id']} order by qihao desc")->fetch(PDO::FETCH_ASSOC);
						 
						 $QIHAO_NEW=$LOLDS['qihao']+1;
						 
						 IF(STRLEN($QIHAO_NEW)==STRLEN($LOLDS['qihao'])){$QIHAO_NEWS=$QIHAO_NEW;}ELSE{$QIHAO_NEWS="0".$QIHAO_NEW;}
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEWS,$SZ_TIME,"");
					 } 
				 }
			 }
		 }
		 
		 //幸运飞艇
		 IF($CL['id']==61){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
					 
					 $PDSHIERD=STRTOTIME(DATE('Y-m-d')."23:59:59");
				 
					 IF($XT_TIME>=$PDSHIERD){$SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3600*24)." ".$HS['jztime']);}ELSE{$SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);}
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF(FLOOR($HS['qihao'])<=9){$HS['qihao']="00".FLOOR($HS['qihao']);}ELSEIF(FLOOR($HS['qihao'])>9 && FLOOR($HS['qihao'])<100){$HS['qihao']="0".FLOOR($HS['qihao']);}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 
		 
		 //七星彩
		 IF($CL['id']==51){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
				 $XT_TIME=TIME();
					 
					 $week = date("w",$XT_TIME);
					 
					 if ($week=='3' || $week=='5' || $week=='0'){    //星期3 就加2天 
						 $SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+2*24*3600)." ".$HS['jztime']);
					 }
					 if ($week=='2'){   //星期2就加3天
						 $SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+3*24*3600)." ".$HS['jztime']);
					 }
					 if ($week=='1' || $week=='4' || $week=='6'){   //星期4 6就加1天
						 $SZ_TIME=STRTOTIME(DATE('Y-m-d',TIME()+1*24*3600)." ".$HS['jztime']);	 
					 }
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 $LOLDS=$db_pdo_link->query("SELECT * FROM kkty_kjjg_list WHERE czid={$CL['id']} order by qihao desc")->fetch(PDO::FETCH_ASSOC);
						 
						 $QIHAO_NEW=$LOLDS['qihao']+1;
						 
						 IF(STRLEN($QIHAO_NEW)==STRLEN($LOLDS['qihao'])){$QIHAO_NEWS=$QIHAO_NEW;}ELSE{$QIHAO_NEWS="0".$QIHAO_NEW;}
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,"");
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //五分时时彩
		 IF($CL['id']==52){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 $SUIJIKAIJUHD=RAND(0,9).RAND(0,9).RAND(0,9).RAND(0,9).RAND(0,9);
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,$SUIJIKAIJUHD);
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //三分时时彩
		 IF($CL['id']==53){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 $SUIJIKAIJUHD=RAND(0,9).RAND(0,9).RAND(0,9).RAND(0,9).RAND(0,9);
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,$SUIJIKAIJUHD);
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //十分时时彩
		 IF($CL['id']==54){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 $SUIJIKAIJUHD=RAND(0,9).RAND(0,9).RAND(0,9).RAND(0,9).RAND(0,9);
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,$SUIJIKAIJUHD);
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //三分赛车
		 IF($CL['id']==56){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 IF($HS['qihao']<10){$HS['qihao']="00".$HS['qihao'];}
						 
						 IF($HS['qihao']>9 && $HS['qihao']<100){$HS['qihao']="0".$HS['qihao'];}
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 $HMARAY=ARRAY();
						 
						 $HMARAY[0]="01";
						 
						 $HMARAY[1]="02";
						 
						 $HMARAY[2]="03";
						 
						 $HMARAY[3]="04";
						 
						 $HMARAY[4]="05";
						 
						 $HMARAY[5]="06";
						 
						 $HMARAY[6]="07";
						 
						 $HMARAY[7]="08";
						 
						 $HMARAY[8]="09";
						 
						 $HMARAY[9]="10";
						 
						 shuffle($HMARAY);;
						 
						 $SUIJIKAIJUHD=$HMARAY[0].$HMARAY[1].$HMARAY[2].$HMARAY[3].$HMARAY[4].$HMARAY[5].$HMARAY[6].$HMARAY[7].$HMARAY[8].$HMARAY[9];
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,$SUIJIKAIJUHD);
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 
		 //五分快三
		 IF($CL['id']==57){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 $SUIJIKAIJUHD=RAND(1,6).RAND(1,6).RAND(1,6);
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,$SUIJIKAIJUHD);
						 
						 
						 
					 }
					 
				 }
				 
				 
				 
			 }
			 
		 }
		 //五分11选5
		 IF($CL['id']==58){
			 
			 $ALLR=$db_pdo_link->query("SELECT * FROM kkty_time WHERE czid={$CL['id']} order by qihao asc")->fetchAll(PDO::FETCH_ASSOC);
			 
			 $IFZXWB="1";
			 
			 FOREACH($ALLR AS $HS ){
				 
				 IF($IFZXWB=="1"){
					 
					 $XT_TIME=TIME();
				 
					 $SZ_TIME=STRTOTIME(DATE('Y-m-d')." ".$HS['jztime']);
					 
					IF($SZ_TIME>=$XT_TIME){
						 
						 $IFZXWB="2";
						 
						 $QIHAO_NEW=DATE('Ymd',$SZ_TIME).$HS['qihao'];
						 
						 $SUD=RAND(1,11);
						 
						 IF($SUD<10){$SUD="0".$SUD;}
						 
						 $SUD_1=RAND(1,11);
						 
						 IF($SUD_1<10){$SUD_1="0".$SUD_1;}
						 
						 $SUD_2=RAND(1,11);
						 
						 IF($SUD_2<10){$SUD_2="0".$SUD_2;}
						 
						 $SUD_3=RAND(1,11);
						 
						 IF($SUD_3<10){$SUD_3="0".$SUD_3;}
						 
						 $SUD_4=RAND(1,11);
						 
						 IF($SUD_4<10){$SUD_4="0".$SUD_4;}
						 
						 $SUIJIKAIJUHD=$SUD.$SUD_1.$SUD_2.$SUD_3.$SUD_4;
						 
						 NEW_CAIPIAO($CL['id'],$QIHAO_NEW,$SZ_TIME,$SUIJIKAIJUHD);
						 
						 
						 
					 }
					 
				 }
				 
			 }
			 
		 }
		 
		 
		 IF($QIHAO_NEW!="" && $CL['id']>0){
			 
			 //检查追号是否存在本期
		 
			 $ZHUIH_K=$db_pdo_link->query("SELECT * FROM kkty_touzhu_list_zh WHERE czid={$CL['id']} AND qihao='$QIHAO_NEW'")->fetchAll(PDO::FETCH_ASSOC);
			 
			 FOREACH($ZHUIH_K  AS $ZH){
				 
				 $MYSQL_ZHIXING_YUJU_A="`czid`,`qihao`,`tzhm`,`tzje`,`dzje`,`tzzs`,`username`,`tzhje`,`zjje`,`ifqs`,`wfid`,`dqpl`,`xzfd`,`fdje`,`kjjg`,`zjzs`,`nbzh`,`tz_time`";
	 
				 $MYSQL_ZHIXING_YUJU_B="'{$ZH[czid]}','{$ZH['qihao']}','{$ZH[tzhm]}','{$ZH[tzje]}','{$ZH[dzje]}','{$ZH[tzzs]}','{$ZH[username]}','{$ZH[tzhje]}','{$ZH[zjje]}','{$ZH[ifqs]}','{$ZH[wfid]}','{$ZH[dqpl]}','{$ZH[xzfd]}','{$ZH[fdje]}','{$ZH[kjjg]}','{$ZH[zjzs]}','{$ZH[nbzh]}','{$ZH[tz_time]}'";
	
				 $db_pdo_link->exec("INSERT INTO `kkty_touzhu_list_no` ($MYSQL_ZHIXING_YUJU_A) VALUES ($MYSQL_ZHIXING_YUJU_B)");
				 
				 $db_pdo_link->exec("DELETE FROM `kkty_touzhu_list_zh` WHERE id={$ZH['id']}"); 
				 
			 }
			 
			 
		 }
	 }
	 
}





//新的一期写入库
FUNCTION NEW_CAIPIAO($CZID,$QIHAO,$JZTIME,$PSS){
	 
	 global $db_pdo_link;
	 
	 IF($PSS==""){$PSS="官方彩无预设";}
	 
	 $IFCUNQIHAO=$db_pdo_link->query("SELECT * FROM kkty_kjjg_list WHERE czid=$CZID AND qihao='$QIHAO'")->fetch(PDO::FETCH_ASSOC);
	 
	 IF($IFCUNQIHAO['id']<1){
		 
		 $MYSQL_ZHIXING_YUJU_A="`czid`,`qihao`,`jztime`,`kjjg`,`iftz`,`ps`";
	 
		 $MYSQL_ZHIXING_YUJU_B="'$CZID','$QIHAO','$JZTIME','0','0','$PSS'";
		 
		 echo "INSERT INTO `kkty_kjjg_list` ($MYSQL_ZHIXING_YUJU_A) VALUES ($MYSQL_ZHIXING_YUJU_B)";echo "\rn";
	
		 $db_pdo_link->exec("INSERT INTO `kkty_kjjg_list` ($MYSQL_ZHIXING_YUJU_A) VALUES ($MYSQL_ZHIXING_YUJU_B)");
		 
		 redis_new_caipiao($CZID,$QIHAO,$JZTIME);

	 }
	 
	 
	 
}
function redis_new_caipiao($CZID,$QIHAO,$JZTIME){
	$redis = new Redis();
	$redis->connect('127.0.0.1','6379');
	$redis->auth('Redis');
	$redis->set("$CZID","$QIHAO,$JZTIME,0");

}


ECHO "</body>";

?>
